package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchVideoMonitor;
import com.ruoyi.system.service.IDispatchVideoMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频监控Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchVideoMonitor")
public class DispatchVideoMonitorController extends BaseController
{
    @Autowired
    private IDispatchVideoMonitorService dispatchVideoMonitorService;

    /**
     * 查询视频监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchVideoMonitor:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchVideoMonitor dispatchVideoMonitor)
    {
        startPage();
        List<DispatchVideoMonitor> list = dispatchVideoMonitorService.selectDispatchVideoMonitorList(dispatchVideoMonitor);
        return getDataTable(list);
    }

    /**
     * 导出视频监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchVideoMonitor:export')")
    @Log(title = "视频监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchVideoMonitor dispatchVideoMonitor)
    {
        List<DispatchVideoMonitor> list = dispatchVideoMonitorService.selectDispatchVideoMonitorList(dispatchVideoMonitor);
        ExcelUtil<DispatchVideoMonitor> util = new ExcelUtil<DispatchVideoMonitor>(DispatchVideoMonitor.class);
        util.exportExcel(response, list, "视频监控数据");
    }

    /**
     * 获取视频监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchVideoMonitor:query')")
    @GetMapping(value = "/{videoMonitorId}")
    public AjaxResult getInfo(@PathVariable("videoMonitorId") Long videoMonitorId)
    {
        return success(dispatchVideoMonitorService.selectDispatchVideoMonitorByVideoMonitorId(videoMonitorId));
    }

    /**
     * 新增视频监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchVideoMonitor:add')")
    @Log(title = "视频监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchVideoMonitor dispatchVideoMonitor)
    {
        return toAjax(dispatchVideoMonitorService.insertDispatchVideoMonitor(dispatchVideoMonitor));
    }

    /**
     * 修改视频监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchVideoMonitor:edit')")
    @Log(title = "视频监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchVideoMonitor dispatchVideoMonitor)
    {
        return toAjax(dispatchVideoMonitorService.updateDispatchVideoMonitor(dispatchVideoMonitor));
    }

    /**
     * 删除视频监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchVideoMonitor:remove')")
    @Log(title = "视频监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoMonitorIds}")
    public AjaxResult remove(@PathVariable Long[] videoMonitorIds)
    {
        return toAjax(dispatchVideoMonitorService.deleteDispatchVideoMonitorByVideoMonitorIds(videoMonitorIds));
    }
}
